﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.ComponentModel;
using NovinMedia.Data;

namespace NovinMedia.Data.Layer
{
    [DataObject(true)]
    public class HoaDonBanHang
    {
		[DataObjectMethod(DataObjectMethodType.Fill)]
		public DataSet SelectAll()
        {
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
                {
 
                };
            return dbo.RunProcedure("pr_HoaDonBanHang_SelectAll", parameters, "HoaDonBanHang");
        }

		[DataObjectMethod(DataObjectMethodType.Fill)]
		public DataSet SelectRow(string MaHD)
        {
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
                {
					new SqlParameter("MaHD",MaHD) 
                };
            return dbo.RunProcedure("pr_HoaDonBanHang_SelectRow", parameters, "HoaDonBanHang");
        }

		[DataObjectMethod(DataObjectMethodType.Insert)]
		public int InsertRow(string MaHD,string MaKH,string MaSoThue,DateTime NgayHD,string TongTienHang,int ThueSuatGTGT,string TienThueGTGT,string PhiVanChuyen,string TongTienThanhToan,string TongTienBangChu,string MaNV)
		{
			int RowsAffected = 0;
			int Result = 0;
			DbObject dbo = new DbObject();
			SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("MaHD",MaHD),
					new SqlParameter("MaKH",MaKH),
					new SqlParameter("MaSoThue",MaSoThue),
					new SqlParameter("NgayHD",NgayHD),
					new SqlParameter("TongTienHang",TongTienHang),
					new SqlParameter("ThueSuatGTGT",ThueSuatGTGT),
					new SqlParameter("TienThueGTGT",TienThueGTGT),
					new SqlParameter("PhiVanChuyen",PhiVanChuyen),
					new SqlParameter("TongTienThanhToan",TongTienThanhToan),
					new SqlParameter("TongTienBangChu",TongTienBangChu),
					new SqlParameter("MaNV",MaNV) 
				};
			Result = dbo.RunProcedure("pr_HoaDonBanHang_Insert", parameters, out RowsAffected);
			return Result;
        }

		[DataObjectMethod(DataObjectMethodType.Update)]
		public int UpdateRow(string MaHD,string MaKH,string MaSoThue,DateTime NgayHD,string TongTienHang,int ThueSuatGTGT,string TienThueGTGT,string PhiVanChuyen,string TongTienThanhToan,string TongTienBangChu,string MaNV)
		{
			int RowsAffected = 0;
			int Result = 0;
			DbObject dbo = new DbObject();
			SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("MaHD",MaHD),
					new SqlParameter("MaKH",MaKH),
					new SqlParameter("MaSoThue",MaSoThue),
					new SqlParameter("NgayHD",NgayHD),
					new SqlParameter("TongTienHang",TongTienHang),
					new SqlParameter("ThueSuatGTGT",ThueSuatGTGT),
					new SqlParameter("TienThueGTGT",TienThueGTGT),
					new SqlParameter("PhiVanChuyen",PhiVanChuyen),
					new SqlParameter("TongTienThanhToan",TongTienThanhToan),
					new SqlParameter("TongTienBangChu",TongTienBangChu),
					new SqlParameter("MaNV",MaNV) 
				};
			Result = dbo.RunProcedure("pr_HoaDonBanHang_Update", parameters, out RowsAffected);
			return Result;
        }

		[DataObjectMethod(DataObjectMethodType.Delete)]
		public int DeleteRow(string MaHD)
		{
			int RowsAffected = 0;
			int Result = 0;
			DbObject dbo = new DbObject();
			SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("MaHD",MaHD) 
				};
			Result = dbo.RunProcedure("pr_HoaDonBanHang_DeleteRow", parameters, out RowsAffected);
			return Result;
        }
    }
}